package org.bwapi.bridge.model;

import java.util.Set;

import org.apache.commons.collections15.Transformer;
import org.bwapi.bridge.swig.PlayerTypeSet;
import org.bwapi.bridge.swig.PlayerTypeSetIterator;
import org.bwapi.bridge.swig.SWIGTYPE_p_PlayerType;
import org.bwapi.bridge.swig.SWIGTYPE_p_std__setT_BWAPI__PlayerType_t;
import org.bwapi.bridge.swig.bridge;
import org.cretz.swig.collection.NativeSet;
import org.cretz.swig.util.SwigUtils;


/**
 * Player type
 * 
 * @see <a href="http://code.google.com/p/bwapi/wiki/PlayerType">PlayerType</a>
 * 
 * @author Chad Retz
 */
public class PlayerType extends BwapiComparable<PlayerType> {
	private static final Transformer<PlayerType, org.bwapi.bridge.swig.PlayerType> FROM = 
		new Transformer<PlayerType, org.bwapi.bridge.swig.PlayerType>() {
			@Override
			public org.bwapi.bridge.swig.PlayerType transform(PlayerType type) {
				return type.getPlayerType();
			}
		};
		
	private static final Transformer<org.bwapi.bridge.swig.PlayerType, PlayerType> TO = 
		new Transformer<org.bwapi.bridge.swig.PlayerType, PlayerType>() {
			@Override
			public PlayerType transform(org.bwapi.bridge.swig.PlayerType type) {
				return new PlayerType(type);
			}
		};	

    public static final PlayerType NOT_USED = new PlayerType(bridge.getNotUsed());
    public static final PlayerType COMPUTER = new PlayerType(bridge.getComputer());
    public static final PlayerType HUMAN = new PlayerType(bridge.getHuman());
    public static final PlayerType RESCUABLE = new PlayerType(bridge.getRescuable());
    public static final PlayerType COMPUTER_SLOT = new PlayerType(bridge.getComputerSlot());
    public static final PlayerType OPEN_SLOT = new PlayerType(bridge.getOpenSlot());
    public static final PlayerType NEUTRAL = new PlayerType(bridge.getPlayerTypeNeutral());
    public static final PlayerType CLOSED_SLOT = new PlayerType(bridge.getClosedSlot());
    public static final PlayerType HUMAN_DEFEATED = new PlayerType(bridge.getHumanDefeated());
    public static final PlayerType COMPUTER_DEFEATED = new PlayerType(bridge.getComputerDefeated());
    public static final PlayerType NONE = new PlayerType(bridge.getPlayerTypeNone());
    public static final PlayerType UNKNOWN = new PlayerType(bridge.getPlayerTypeUnknown());

    public static Set<PlayerType> allPlayerTypes() {
    	return newSet(bridge.allPlayerTypes());
    }
    
    static Set<PlayerType> newSet(SWIGTYPE_p_std__setT_BWAPI__PlayerType_t nativeSet) {
		return new NativeSet<PlayerType, org.bwapi.bridge.swig.PlayerType>(
				org.bwapi.bridge.swig.PlayerType.class, PlayerTypeSetIterator.class, 
				nativeSet, PlayerTypeSet.class, FROM, TO);
    }
    
    /**
     * Not implemented
     * 
     * @param name
     * @return
     * 
     * @deprecated Not implemented
     */
    @Deprecated
    public static PlayerType getPlayerType(String name) {
    	throw new UnsupportedOperationException();
    }
	
	private final org.bwapi.bridge.swig.PlayerType playerType;
	
	PlayerType(org.bwapi.bridge.swig.PlayerType playerType) {
		this.playerType = playerType;
	}
	
	PlayerType(SWIGTYPE_p_PlayerType pointer) {
		this(SwigUtils.getSwigPointer(SwigUtils.getSwigPointer(pointer), 
				false, org.bwapi.bridge.swig.PlayerType.class));
	}

	public PlayerType() {
		this(new org.bwapi.bridge.swig.PlayerType());
	}

	public PlayerType(int id) {
		this(new org.bwapi.bridge.swig.PlayerType(id));
	}

	public PlayerType(PlayerType other) {
		this(new org.bwapi.bridge.swig.PlayerType(other.getPlayerType()));
	}
	
	org.bwapi.bridge.swig.PlayerType getPlayerType() {
		return playerType;
	}

	@Override
	public PlayerType opAssign(PlayerType other) {
		return new PlayerType(playerType.opAssign(other.getPlayerType()));
	}

	@Override
	public boolean opEquals(PlayerType other) {
		return playerType.opEquals(other.getPlayerType());
	}

	@Override
	public boolean opNotEquals(PlayerType other) {
		return playerType.opNotEquals(other.getPlayerType());
	}

	@Override
	public boolean opLessThan(PlayerType other) {
		return playerType.opLessThan(other.getPlayerType());
	}

	@Override
	public int getID() {
		return playerType.getID();
	}

	public String getName() {
		return playerType.getName();
	}
}
